I posted this almost 13 days ago with zero answers, so I took some time to look through a bunch of documentation and did a ton of trial and error. Please Braincloud for the love of god add this to your API.
Rhino does not handle Arrays the way that other coding languages do.
I figured it out, unlike most arrays that return an array after you call push- Rhino returns the new length. So if you call push, don't set it's value.
var copyArray = []; //I assume this line tells it to be an array
for (var i = 0; i < postResult.data..length; i++)
{
copyArray[i] = postResult.data[i];
//arrays do not behave like .Net arrays, you can change length without initializing, so you just set each index to the index of the array you're copying
}
copyArray.push(variableToAdd);
//Do NOT set this as the value of your array, the push method returns an int (length of array) NOT an array!
//you probably dont need to call push at all to add to the array as shown in the for loop above if you already know your length or want a specific length
Then just set your value to the variable, like this
var entityData = {
"variableName": copyArray
};
//No need to call Array(copyArray) or any of the prototype. slice stuff. If you call Array() you'll just nest the array a second time.
Use this page for further info on functions you can do with arrays.